package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.CouponUseRecord;
import com.micro.modual.extension.CouponUseRecordExtension;
import com.micro.modual.mapper.CouponUseRecordMapper;
import com.micro.modual.model.bo.couponuserecord.CouponUseRecordBO;
import com.micro.modual.service.CouponUseRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>优惠券使用记录表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("couponUseRecordService")
public class CouponUseRecordServiceImpl extends AbstractBasicsServiceImpl<CouponUseRecord,Long> implements CouponUseRecordService {

    @Autowired
    private CouponUseRecordMapper couponUseRecordMapper;

    /**
     * <h2>新增优惠券使用记录表详情</h2>
     * @param couponUseRecordBO {@link CouponUseRecordBO} 优惠券使用记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addCouponUseRecord(CouponUseRecordBO couponUseRecordBO) {
        CouponUseRecord couponUseRecord = CouponUseRecordExtension.converAddCouponUseRecord(couponUseRecordBO);
        couponUseRecordMapper.insertSelective(couponUseRecord);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改优惠券使用记录表详情</h2>
     * @param couponUseRecordBO  {@link CouponUseRecordBO} 优惠券使用记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editCouponUseRecord(CouponUseRecordBO couponUseRecordBO) {
        CouponUseRecord couponUseRecord = CouponUseRecordExtension.converEditCouponUseRecord(couponUseRecordBO);
        couponUseRecordMapper.updateByPrimaryKeySelective(couponUseRecord);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除优惠券使用记录表信息</h2>
     * @param id  优惠券使用记录表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteCouponUseRecord(Long id) {
        couponUseRecordMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
